package impl.controller;

import entity.User;
import entity.User_Sex;
import face.service.IUserService;
import impl.service.UserServiceImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * @author futao
 * Created on 2018/2/5 - 17:23.
 */
@Controller
public class LoginController {
    @Resource
    private IUserService userService;

    private final static Log logger = LogFactory.getLog(LoginController.class);

    @RequestMapping(value = "login", method = RequestMethod.GET)
    public ModelAndView login() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("WEB-INF/content/user/login.jsp");
        return modelAndView;
    }


    @RequestMapping(value = "login", method = RequestMethod.POST)
    public String login(
            @RequestParam(value = "name", required = true, defaultValue = "") String name,
            @RequestParam(value = "password", required = true, defaultValue = "") String password
    ) {
        userService.add();
        System.out.println("======================loginPOST");
        ModelAndView modelAndView = new ModelAndView();
        logger.debug(name);
        logger.debug(password);
        userService.list();
        return "world";
    }
}
